clear locks issue

Hello,

I have the following code to chuck out troublesome users in the middle of the night prior to archiving projects/ modules. It works in GUI mode on my client, but bafflingly fails to clear module share locks on a client on the server in batch mode. I'm sure some of you guys must have come accross this issue before, if so what's the work around - its defeating me at the moment, might have to resort to restarting the services instead, nicer to do it in dxl though. Note that the loop that scrolls through the database appears to do precisely nothing and shouldn't be needed, just chucked it in in exasperation!

// Remove any locks in the database
void ClearAllLocks() {
    LockList Llist
        Lock lockItem
        string errMess
        Skip lockSkip = create
        int count=0
        cout<< "Clearing database locks...\n"
        Llist = getLocksInDatabase(true)
        for lockItem in Llist do {
            put(lockSkip, count++, lockItem)
        }
        for lockItem in lockSkip do {
                string thisUser = lockItem.user
                cout << "Attempting to remove lock for " thisUser "\n"
                errMess = remove(lockItem)
            if(! null errMess) cout<< "Error Removing Lock: " errMess "\n"
            else cout << "Succesfully removed lock for " thisUser "\n"
        }
        
        delete Llist
        delete lockSkip
        
        //the above is not removing the share locks form the database so need to scroll through each module individually - 
        Module thisMod
        
        for thisMod in database do {
                Llist = getLocksInModule(module(fullName(thisMod)), true)
                lockSkip = create
                for lockItem in Llist do {
                    put(lockSkip, count++, lockItem)
                }
                for lockItem in lockSkip do {
                        string thisUser = lockItem.user
                        cout << "Attempting to remove Shareable lock for " thisUser " on " fullName(thisMod) "\n"
                        errMess = remove(lockItem)
                    if(! null errMess) cout<< "Error Removing Lock for " thisUser " on " fullName(thisMod) "\n" errMess "\n"
                    else cout << "Succesfully removed lock for " thisUser " on " fullName(thisMod) "\n"
                    delete Llist
                        delete lockSkip
                }
        }
}

Richard_Good - Fri Jan 18 10:05:57 EST 2013

Re: clear locks issue
Johnny_P - Mon Jan 21 02:57:34 EST 2013

Hi,

I wrote a little batch-file to solve this issue.
We use the dbadmin-tool to write all connected users in a temp-textfile and then I kill all connections (except the dbadmin connection itself).

I have no clue about batch-files, so I'm sure, that this code is far from beeing perfect, but it works ;)
 

@echo off
 
"C:\Program Files (x86)\IBM\Rational\DOORS\9.3\bin\dbadmin" -data PORT@SERVER -user 2> C:\Working_Directory\tmp\DOORS_User_Connect.txt
FOR /F "eol=; tokens=3* delims=:, " %%a in (C:\Working_Directory\tmp\DOORS_User_Connect.txt) do (
rem if "%%a" EQU "**********" "C:\Program Files (x86)\IBM\Rational\DOORS\9.3\bin\dbadmin" -data PORT@SERVER -k %%a  
"C:\Program Files (x86)\IBM\Rational\DOORS\9.3\bin\dbadmin" -data PORT@SERVER -k %%a
)
 
:END
endlocal

 


Regards,
Johnny

 

Re: clear locks issue
Richard_Good - Mon Jan 21 12:45:46 EST 2013

Johnny_P - Mon Jan 21 02:57:34 EST 2013

Hi,

I wrote a little batch-file to solve this issue.
We use the dbadmin-tool to write all connected users in a temp-textfile and then I kill all connections (except the dbadmin connection itself).

I have no clue about batch-files, so I'm sure, that this code is far from beeing perfect, but it works ;)
 

@echo off
 
"C:\Program Files (x86)\IBM\Rational\DOORS\9.3\bin\dbadmin" -data PORT@SERVER -user 2> C:\Working_Directory\tmp\DOORS_User_Connect.txt
FOR /F "eol=; tokens=3* delims=:, " %%a in (C:\Working_Directory\tmp\DOORS_User_Connect.txt) do (
rem if "%%a" EQU "**********" "C:\Program Files (x86)\IBM\Rational\DOORS\9.3\bin\dbadmin" -data PORT@SERVER -k %%a  
"C:\Program Files (x86)\IBM\Rational\DOORS\9.3\bin\dbadmin" -data PORT@SERVER -k %%a
)
 
:END
endlocal

 


Regards,
Johnny

 

Tried that on the test server and it certainly seems to chuck people out ok. I prefer this to restarting the service. I'll dream up an overnight test case before running it on all databases. Many thanks for the tip. The batch file looks fine to me, I guess the commented out EQU bit is used to kick out a particular user the administrator doesn't like!

Re: clear locks issue
Johnny_P - Tue Jan 22 02:40:56 EST 2013

Richard_Good - Mon Jan 21 12:45:46 EST 2013
Tried that on the test server and it certainly seems to chuck people out ok. I prefer this to restarting the service. I'll dream up an overnight test case before running it on all databases. Many thanks for the tip. The batch file looks fine to me, I guess the commented out EQU bit is used to kick out a particular user the administrator doesn't like!

No problem, glad I could help.

Oh thanks for reminding me! The commented out EQU line was for testing purposes only. We didn't have had a test server and with this line I was able to only kick myself or a test user and see if it works.

Regards Johnny

Re: clear locks issue
Richard_Good - Tue Jan 29 07:22:30 EST 2013

Johnny_P - Tue Jan 22 02:40:56 EST 2013
No problem, glad I could help.

Oh thanks for reminding me! The commented out EQU line was for testing purposes only. We didn't have had a test server and with this line I was able to only kick myself or a test user and see if it works.

Regards Johnny

Hi Jonny,
Needed to combine my script and your script, share locks on projects/ folders sometimes remain if I do not, but my "on server" project and module archive now work reliably. Thanks again for the tip.

Richard